package ar.edu.utn.xcontainer;

import java.util.Hashtable;
import java.util.Iterator;

import ar.edu.utn.bean.TypeOfProperty;

import ar.edu.utn.xcontainer.interfaces.ComponentDescription;

public class ComponentFactory {

	/**
	 * @param args
	 */

	public ComposeComponentDescription create(String key, String clazz, Container container){
		ComposeComponentDescription cd=new ComposeComponentDescription(key,clazz,container);
		return cd;
	}
	
	public ComposeComponentDescription create(Container container){
		ComposeComponentDescription cd=new ComposeComponentDescription(container);
		return cd;	
	}

	public static void resolveDependency(String bean, 
			Hashtable<TypeOfProperty , ComponentDescription> dependencies){
		Iterator<TypeOfProperty> typeOfPropertyIterator = dependencies.keySet().iterator();
		
		while(typeOfPropertyIterator.hasNext()){
			TypeOfProperty aTypeOfProperty = typeOfPropertyIterator.next();
			
			ComponentDescription aComponentDescription = dependencies.get(aTypeOfProperty);
			
			aComponentDescription.satisfyDependency();
			
		}
	}
	
	//TODO eliminar si no se usa
	/*
	 * public static ComponentDescription setComponentDescription(Class classe,
	 * TypeOfProperty top) throws Exception{ /* La finalidad del metodo es poder
	 * separar lo que seria un componente compuesto de uno simple.
	 * 
	 * Si este, esta dado por una componente simple (ya se que porque termina
	 * siendo una variabe int o Integer o String o Long), del bean
	 * 
	 * 
	 * ComponentDescription cd = TypeOfPropertyAnalizer.analizeType(top);
	 * 
	 * cd.setDependantComponentClass(classe);
	 * 
	 * return null; }
	 */
}
